<?php 
function view_answer_tweet($id_tweet) {
	require("model/answerBD.php");
	$tab = select_answer_tweet($id_tweet);
	if(sizeof($tab['id_answer']) > 0) {
		require("view/tweet.tpl");
	} else {
		$message = "Aucune reponse disponible pour le moment sur le tweet";
		require("view/error.tpl");
	}
}
function add_answer($id_tweet) {
	if(count($_POST)==0) {
		require("view/tweet.tpl");
	} else {
		if (isset($_SESSION['id_user'])) {
			require("model/answerBD.php");
			if(add_answer_db($id_tweet, $_SESSION['id_user'], $_POST['text_answer'])) {
				$message = "reponse inseree.";
				require("view/valid.tpl");
			} else {
				require("view/tweet.tpl");
			}
		}
	}
}
?>